'use strict';

function compute_chain_median(collection) {
  let result;
  let arr = collection.split("->");

  
  let s1 = arr.map(function(x){
    return Number(x);
  })
  

  let s2=s1.sort((a,b)=>a-b);
 
  let m=s2.length/2;

 if(s2.length%2 === 0){
   result = (s2[m]+s2[m-1])/2;
 }else{
   result = s2[parseInt(m)];
 }
 console.log(result);
 return result;
  //在这里写入代码
}
compute_chain_median('1->4->6->2->3->10->9->8->11->20->19->30');
module.exports = compute_chain_median;
